<?php
//menu
echo "
	<div style='display:block; text-align:right; float:right;'>
		<div class='menu_messages'><a href='/messages/compose'>" . Language::Get('Compose') . "</a></div> 	
		<div class='menu_messages_active'><a href='/messages/inbox'>" . Language::Get('Inbox') . "</a></div> 
		<div class='menu_messages'><a href='/messages/outbox'>" . Language::Get('Outbox') . "</a></div>
	</div>"; 

//Inbox
echo "
	<div class='pageHeading'>" . Language::Get('Inbox') . "</div>
	<table cellspacing='0' cellpadding='4' border='0' width='100%' class='messageList'>
	<tr>
		<th>". Language::Get('From whom') . "</th>
		<th>". Language::Get('Date') . "</th>
		<th>". Language::Get('Time') . "</th>
		<th>". Language::Get('Topic') . "</th>
		<th>". Language::Get('Actions') . "</th>
	";

	if (count ($this->data['messages']) == 0)
	{
		echo "<tr><td colspan=5>No records</td></tr>"; 
	}
	
foreach ($this->data['messages'] as $key => $value)
{
	$datetime = explode(' ', $value['datetime']);
	echo "<tr>
			<td>" . $value['client_email'] . "</td>
			<td>" . $datetime[0] .", ". $datetime[1] ." ". $datetime[2] . "</td>
			<td>" . $datetime[3] . "</td>
			<td>" . HtmlsHelper::ShortenText($value['topic'], 10) . "</td>
			<td>
				<a href = '/messages/compose/?recepient=" . $value['recepient_reference'] . "'> ". Language::Get('Reply') . "</a> |
				<a href = '/messages/show/" . $value['id'] . "'> ". Language::Get('View') . "</a>
			</td>
		</tr>";		
}
	
echo "</table>";

//pagination
echo "<div style = 'padding: 15px; '>".HtmlsHelper::Pagination($this->data['num_rows'])."</div>";
	
?>